<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Ingesup {

    function __construct() {
        $this->ci =& get_instance();
    }

    function render($view, $data='') {
        $controller = $this->ci->router->fetch_class();
        $action = $this->ci->router->fetch_method();

        $header_data = array(
            'title' => lang('title_'.$controller.'_'.$action),
            'css' => $controller,
            'js' => $controller,
        );

        if($this->ci->tank_auth->is_logged_in()) {
            $this->ci->load->model(array('user_profiles_model'));

            $header_data['userfullname'] = $this->ci->user_profiles_model->get_user_fullname($this->ci->tank_auth->get_user_id());
            $data['user_id'] = $this->ci->tank_auth->get_user_id();
            $header_data['user_id'] = $data['user_id'];
            $header_data['user_fullname'] = $this->ci->user_profiles_model->get_user_fullname($header_data['user_id']);
            $sidebar_data['role'] = $this->ci->tank_auth->get_role();
        } else
            $sidebar_data = '';

        $footer_data = '';

        $this->ci->load->view('layout/header', $header_data).
        $this->ci->load->view('layout/sidebar', $sidebar_data).
        $this->ci->load->view($view, $data).
        $this->ci->load->view('layout/footer', $footer_data);
    }
}